<g:render template="header" ></g:render>

<!--主体-->
<div class="load_blk load_blk_ying upload">
    <div class="user_blk1 f_l">
            <div class="user_head">
                <g:if test="${user?.photoImage}">
                    <img src="../${user?.photoImage}"  alt="头像" />
                </g:if>
                <g:else>
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="${resource(dir: '/assets/img', file: 'headp_140.jpg')}" alt="photobox" class="userPic"></a>
                </g:else>
            </div>
    </div>
    <!--用户信息-->
    <div class="user_blk12 f_l">
        <div style="height: 175px; padding-top: 25px;">
            <h4 class="nav_title mLe_20">用户名称：${user?.nickName}</h4>
            <p class="blk_p">用户身份</p>
            <p class="blk_p"><span class="mRi_30">所在地：北京</span> <span class="mRi_30">常用设备：Canon EOS D60</span> <span>影龄：5-10年</span></p>
        </div>
        <div class="user_jianj1">
            <p>${user?.presentation}</p>
        </div>
    </div>
    <!--/用户信息-->
</div>
<div class="kong_20"></div>
<div class="load_blk load_blk_ying mBo_10 load1">
    <div class="blk3_2">
        <div class="s1_title">
            <h3 class="f_l"><span class=" tubiao3 tubiao3_3">&nbsp;</span>他的作品(${num})</h3>
        </div>

        <!--作品区-->
        <input type="hidden" value="${max}" id="maxId" />
        <input type="hidden" value="${offset}" id="offsetId" />
        <input type="hidden" value="${userId}" id="userId" />

        <!---->

        <div id="main" class="anli_pic" style="width: 1140px;padding-bottom: 0px;">
            <div class="flow" ></div>
            <div class="flow" ></div>
            <div class="flow" ></div>
            <div class="flow" ></div>
            <div class="flow" ></div>
        </div>

        <div class="bottomBor"></div>%{--遮住底部阴影--}%
    </div>
    <!--/blk3-->
</div>
<!--/主体-->
<script>
    var ajaxPhoto = function(max,offset,userId){
        if($("#maxId").attr("name")){
            return;
        }
        $("#maxId").attr("name",'request')

        $.ajax({
            type:"POST",
            url:"<g:createLink controller='home' action='bestPhotographer'/>",
            data:{max:max,offset:offset,json:1,userId:userId},
            dataType:'json',
            beforeSend:function(){
            },
            success:function(data){
                console.log(data)
                $("#maxId").attr("name","");
                $('#maxId').val(data.max);
                $('#offsetId').val(data.offset);
                var d = data.photoList;
                var n = d.length/5;
                var j=0;
                for(var i = 0 ; i < n ; i++){
                    $(".flow").each(function() {
                        if (d[j]) {
                            var r = d[j]
                            var html = [];
                            html.push('<div class="list"><a href="../photo/show/'+ r.id+'">');
                            html.push('<div class="anlipic_tu"><img src="../' + r.smallImagePath + '"  border="0"/></div>');
                            html.push('<div class="anlipic_sm"><h5>' + r.name + '</h5> <p>作者：' + r.username +'</p><p style="color:#f4972a ">价格:￥'+ r.price+'</p></div>');
                            html.push('</a></div>');
                            html.push('<div class="heng_line clear"></div>');
                            $(this).append(html.join(' '));
                            j++;
                        }else{
                            $("#maxId").attr("name","request");
                        }
                    });
                }
            },
            error: function (data, status, e)//服务器响应失败处理函数
            {
                sAlert(e+'没有发现');
            }
        });
    }
    $(document).ready(function(){

        //初始化数据
        ajaxPhoto(10,0,$('#userId').val());
        $(window).scroll(function(){
            // 被卷去的高度
            var scrollTop = document.body.scrollTop||document.documentElement.scrollTop;
            // 页面高度
            var pageHeight = $(document).height();
            // 可视区域高度
            var viewHeight = $(window).height();
            //alert(viewHeight);
            //当滚动到底部时
            if((scrollTop+viewHeight)>(pageHeight-20)){
                ajaxPhoto($('#maxId').val(),$('#offsetId').val(),$('#userId').val());
            }
        });
    });

    /*上传按钮*/
    $('#upLoadBtn').click(function(){
        if(!'${session.userId}'){
            sAlert("请登录！");

        }else{
            window.location.href="/photobox/photo/add"
        }
    });
</script>
<g:render template="footer" ></g:render>

